<?php
$space = Blyn::app()->getActiveSpace();
$wxAppId = $space->getAttribute('wechat_appid')->getValue();
$wxAppSecret = $space->getAttribute('wechat_appsecret')->getValue();
 $wechat = new BWeChatClass($wxAppId,$wxAppSecret);
//$userOpenidArray = array();
//for($i = 0,$j = 0;$i<30;$i++){
//    $userOpenidArray[$j] = $space->getAttribute('wechat_openid'.$i)->getValue();
//    $j++;
//}
$userOpenidArray = $space->getAttribute('wechat_openid')->getValue();
$usersControl = new BUIControl();
$activeOperation = Blyn::app()->getActiveOperation();


?>
<script type="text/javascript"> 
  $(document).ready(function(){ 
    $("#selectAll").click(function(){ 
      if($(this).attr("checked")=="checked"){ 
        $(":checkbox").attr("checked",true); 
      }else{ 
        $(":checkbox").attr("checked",false); 
      } 
    }); 
    
  }); 
 </script> 
<style  type="text/css">
    .shiftUser{
/*        padding: 0 12px;
        border-bottom-width: 0;background-color: #e1e1e1;
        border-bottom: 1px solid #c4c4c4;*/
    }
    .groupoption{
        display: inline-block;
        position: relative;
        width: 95px;
        line-height: normal;
        text-align: left;margin-right: .5em;
    }
    .groupoption2{
        width: 95px;height: 30px;
    }
    .group{
    display: inline-block;
    position: relative;
    width: 95px;
    line-height: normal;
    text-align: left;margin-right: .5em;
    }
</style>
<!--<div>
    <?php // $usersControl->render(); ?>
</div>-->
<div>
    <table class="table table-hover">
        <thead>
            <tr>
                <th>
                    <input type="checkbox"  id="selectAll"> 
                </th>
                <th>头像</th>
                <th>昵称</th>
                <th>操作</th>
            </tr> 
        </thead>
        <tbody>
            <?php
            $i = 0;
            foreach($userOpenidArray as $value)
            {
              if ($i < 5)
              {
                 $userInfoArray = $wechat->get_user_info($value);
            ?>
                <tr>
                    <td style="width: 40px;"><label class="checkbox">
                            <input type="checkbox" name="subBox[]" value="<?php echo $userInfoArray["openid"]; ?>"> 
                        </label>
                    </td>
                    <td style="width: 50px;"> 
                       <img src="<?php echo $userInfoArray["headimgurl"]; ?>" style="width: 48px;
                        height: 48px;">
                     </td>
                      <td style="width: 120px;">
                          <?php echo $userInfoArray["nickname"]; ?>
                     </td>
                     <td>
                        <div class="row-fluid">
                            <?php echo  $activeOperation->getUIManager()->getAjaxLink(array('name'=>'发送消息','id'=>'sendSingleMessage'), array('userName' => $userInfoArray['nickname'],'userOpenid' => $userInfoArray['openid'],'htmlOptions' => array('role'=>'button','data-toggle'=>'modal'))); ?>
                             <!--<a href="" role="button" data-toggle="modal">发送消息</a>-->
                            &nbsp;|&nbsp;
                            <a href="#comment" role="button" data-toggle="modal">修改备注</a>
                        </div>
                    </td>
                </tr>
              
                <?php  
                $i++;
                }
                 else
                {
                   break;
                }
            }
                ?>
        </tbody>
    </table>
    <div id="comment" class="modal hide fade"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3>添加备注</h3>
    </div>
        <div class="modal-body well" style="padding: 90px 0 110px;text-align: center;">
            <div style="display: inline-block;text-align: left;">
                <input type="text" style="border: 0;outline: 0;height: 22px;margin: 4px 0;border: 1px solid #c3c3c3;
box-shadow: inset 0 1px 1px rgba(0,0,0,0.15);" >
            </div>
        </div>

    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
        <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">保存</button>
    </div>
</div>
    <div class="shiftUser">
       <label class="control-label" style="display: inline" >将选中粉丝转移到分组中</label>
       <div class="groupoption">
          <select style="width: 95px;height: 30px;">
                <option>未分组</option>
                <option>黑名单</option>
                <option>星标组</option>
              </select>
            </div>
      <label class="control-label" style="display: inline">按分组查看粉丝</label>
      <div class="group">
          <select class="groupoption2">
                <option>未分组</option>
                <option>黑名单</option>
                <option>星标组</option>
              </select>
            </div>
    </div>  

 </div>
